package socketmvc.core.filter;

import socketmvc.core.context.IContext;
import socketmvc.core.packets.basic.IPacket;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;

public class FilterHandler {
    private final LinkedList<IFilter> filters = new LinkedList<>();

    public void addFilter(IFilter filter){
        filters.addFirst(filter);
        filters.sort(Comparator.comparingInt(IFilter::order));
    }

    public void addFilter(Collection<IFilter> filter){
        filters.addAll(filter);
        filters.sort(Comparator.comparingInt(IFilter::order));
    }

    public List<IFilter> getFilters(IContext context, IPacket packet){
        return filters;
    }

}
